<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
if(!empty($_POST) && isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
{
    require_once "common.inc.php";
    $data = "";
    $post = $_POST;
    if(!is_numeric(intval($post['cid'])) || !is_numeric(intval($post['getnum'])))
    {
        die('提交请求时遇到错误!!');
    }
    switch($post['action'])
    {
        case 'ajaxTabsContent':
            $sql = "SELECT * FROM cms_archives WHERE typeid = $post[typeid] ORDER BY pubdate DESC LIMIT $post[getnum]";
            $result = $dsql->Execute('me',$sql);
            $i = 0;
            while($row = $dsql->GetArray('me'))
            {
                $i++;
                $str = setDataByType($post['types']);
                $str = str_replace('{linkurl}', '/plus/view.php?aid='.$row['id'], $str);
                $str = str_replace('{imgurl}', $row['litpic'], $str);
                $str = str_replace('{texttitle}', $row['title'], $str);
                $data .= $str;
            }
            echo $data;
            break;
    }
}

function setDataByType($types)
{
    switch ($types)
    {
        case "images":
            $htmlstr = "<li><a href='{linkurl}' target='_blank'><img src='{imgurl}' border='0' alt='{texttitle}' /></a></li>\n";
            break;
        case "textlist":
            $htmlstr = "<li><a href='{linkurl}' target='_blank'>{texttitle}</a></li>";
            break;
        default:
            return false;
    }
    return $htmlstr;
}
?>
